package com.a3dweijing.wetouch2.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;


import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.base.BaseActivity;
import com.a3dweijing.wetouch2.bean.VideoType;
import com.flyco.tablayout.SlidingTabLayout;

import java.util.List;

/**
 * Created by yxd on 2017/12/27.
 */

public class PartitionTypeAvtivity extends BaseActivity {
    private int position;
    private SlidingTabLayout slidingTabLayout;
    private ViewPager viewPager;
    private List<VideoType> videoTypes;
    private TextView type_name;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_partition_type);
        type_name= (TextView) findViewById(R.id.partition_type_name);
        slidingTabLayout= (SlidingTabLayout) findViewById(R.id.partition_type_slidingtavleyout);
        viewPager= (ViewPager) findViewById(R.id.partition_type_viewpager);
        findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        videoTypes= (List<VideoType>) getIntent().getSerializableExtra("types");
        position=getIntent().getIntExtra("position",0);
        if (videoTypes!=null && videoTypes.size()>0)
        {
            type_name.setText(videoTypes.get(position).getWc_type_name());
            viewPager.setAdapter(new PartitionViewpagerAdapter(getSupportFragmentManager(),videoTypes));
            slidingTabLayout.setViewPager(viewPager);
        }
        viewPager.setCurrentItem(position);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                type_name.setText(videoTypes.get(position).getWc_type_name());
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }
}
